const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
    entry: './src/index.js',
    output: {
        path: __dirname,
        filename: './dist/index.js'
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: './index.html'
        })
    ],
    devServer: {
        contentBase: path.join(__dirname, './dist'),
        open: true,
        port: 9000
    },
    module: {
        rules: [
            {
                test: /\.css$/i,
                use: ["style-loader", "css-loader"],
            },
            {
                test: /\.(eot|svg|ttf|woff|woff2)(\?\S*)?$/,
                loader: 'file-loader',
                options: {
                    limit: 20000,
                    name: './dist/fonts/[name]-[hash].[ext]'
                }
            },
            {
                test: /\.js$/, //处理以.js结尾的文件
                exclude: /node_modules/, //处理除了nodde_modules里的js文件
                loader: 'babel-loader' //用babel-loader处理
            }
        ]
    }
}